package com.winit.openapi.ums.controller;


import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;

import com.alibaba.fastjson.JSON;
import com.winit.common.spi.context.CommandContext;
import com.winit.openapi.controller.BaseController;
import com.winit.openapi.model.RequestMsg;
import com.winit.openapi.model.ResponseMsg;
import com.winit.ums.spi.customer.EbayAccountService;
import com.winit.ums.spi.customer.command.AddEbayAccountCommand;
import com.winit.ums.spi.customer.command.ModifyEbayAccountCommand;
import com.winit.ums.spi.customer.command.QueryEbayAccountCommand;
import com.winit.ums.spi.customer.vo.EbayAccountVo;

/**
 * ebay账号Controller
 * @author qibin.tang
 *
 */
@Controller
@RequestMapping(value = "/ums/ebayAccount")
public class EbayAccountController extends BaseController {

	@Resource
    private EbayAccountService umsEbayAccountService;
	
	/**
	 * 添加ebay账号
	 * @param requestMsg
	 * @param responseMsg
	 * @return
	 */
    @RequestMapping(value = "/addEbayAccount")
    public String addEbayAccount(@ModelAttribute RequestMsg requestMsg, @ModelAttribute ResponseMsg responseMsg) {
    	AddEbayAccountCommand command = JSON.parseObject(requestMsg.getData().toString(),AddEbayAccountCommand.class);
        command.setCtx(CommandContext.getContext());
        umsEbayAccountService.addEbayAccount(command);
        return SUCCESS;
    }
    
    /**
	 * 停用，启用,删除，修改ebay账号缩写
	 * @param requestMsg
	 * @param responseMsg
	 * @return
	 */
    @RequestMapping(value = "/modifyEbayAccount")
    public String modifyEbayAccount(@ModelAttribute RequestMsg requestMsg, @ModelAttribute ResponseMsg responseMsg) {
    	ModifyEbayAccountCommand command = JSON.parseObject(requestMsg.getData().toString(),ModifyEbayAccountCommand.class);
    	command.setCtx(CommandContext.getContext());
    	umsEbayAccountService.modifyEbayAccount(command);
        return SUCCESS;
    }
    
    /**
	 * 停用，启用,删除，修改ebay账号缩写
	 * @param requestMsg
	 * @param responseMsg
	 * @return
	 */
    @RequestMapping(value = "/queryEbayAccount")
    public String queryEbayAccount(@ModelAttribute RequestMsg requestMsg, @ModelAttribute ResponseMsg responseMsg) {
    	QueryEbayAccountCommand command = JSON.parseObject(requestMsg.getData().toString(),QueryEbayAccountCommand.class);
    	command.setCtx(CommandContext.getContext());
    	List<EbayAccountVo> list = umsEbayAccountService.queryEbayAccount(command);
    	responseMsg.setData(list);
        return SUCCESS;
    }
    
    
}
